/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.vista;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Lindemann
 */
@ManagedBean
@SessionScoped
public class AccessBean {

    //------variables(propiedades)----------------------------------------
    private String name;
    private String password;
    //-------------constructor--------------------------------------------

    public String getPassword() {
        return password;
    }
//------------metodos GET y SET-------------------------------------------

    public void setPassword(String password) {
        this.password = password;
    }

    public AccessBean() {
    }

    public String getName() {
        System.out.println("Entro al GET");
        return name;
    }

    public void setName(String name) {
        System.out.println("Entro al SET");
        this.name = name;
    }
    //------------------Acciones----------------------------

    public String validarEntrada() {//entrada en lugar de login

        if (name.equals("toto") && password.equals("12")) {//////////////////////no entra al metodo
            FacesContext context = FacesContext.getCurrentInstance();
            context.getExternalContext().getSessionMap().put("USUARIO_LOGUEADO", name);
            return "MenuPrincipal";
        } else {
            return "Pagina2";
        }
    }
    //-------------------Listeners---------------------------
}
